package com.geekjob1120.geekjob1120pay;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.function.client.WebClient;

@SpringBootApplication
@EnableFeignClients
@EnableDiscoveryClient(autoRegister = false)
public class Geekjob1120CoffeeApplication {

	public static void main(String[] args) {
		SpringApplication.run(Geekjob1120CoffeeApplication.class, args);
	}

	@Bean
	WebClient webClient(WebClient.Builder builder){
		return builder.baseUrl("http://localhost:18808").build();
	}

//	@Bean
	IRule rule(){
		return new RandomRule();
	}

	@Bean
	RestTemplate restTemplate(){
		return new RestTemplate();
	}

	@Bean
	DeferringLoadBalancerExchangeFilterFunction DeferringLoadBalancerExchangeFilterFunction(ObjectProvider exchangeFilterFunctionProvider){
		return new DeferringLoadBalancerExchangeFilterFunction(exchangeFilterFunctionProvider);
	}

}
